<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
  </head>

  <body>
    <div id="app">
      <button @click="fn">点击</button>
      <button @click="count++">累加</button>{{count}}
      <button @click="fn1">累加3</button>
      <p>{{num}}</p>

      <br />
      <button @click="fn2(5)">累加n</button>
      <p>{{temp}}</p>
    </div>
    <script>
      Vue.config.productionTip = false;

      const vm = new Vue({
        el: "#app",
        data() {
          return {
            count: 1,
            num: 1,
            temp: 1,
          };
        },
        methods: {
          fn() {
            console.log(this);
            alert("又来了老弟");
          },
          fn1() {
            this.num += 3;
          },
          fn2(n) {
            this.temp += n;
          },
        },
      });
    </script>
  </body>
</html>
